package com.habitreformer.core.task;

import junit.framework.TestCase;

public class TaskImplTest extends TestCase
{
	TaskImpl task;

	public void setUp() throws Exception
	{
		task = new TaskImpl();
	}

	public void testTaskImpl()
	{
		TaskImpl taskImpl = new TaskImpl();
		assertEquals(taskImpl.getRating(), TaskRating.UNRATED);
		assertEquals(TaskStatus.UNSTARTED, taskImpl.getStatus());
	}

	public void testSetRating()
	{
		TaskImpl taskImpl = new TaskImpl();
		taskImpl.setRating(TaskRating.EXCELLENT);
		assertEquals(TaskRating.EXCELLENT, taskImpl.getRating());
	}

	public void testSetStatus()
	{
		TaskImpl taskImpl = new TaskImpl();
		taskImpl.setStatus(TaskStatus.PROCEEDING);
		assertEquals(TaskStatus.PROCEEDING, taskImpl.getStatus());
	}

	public void testIsFinished()
	{
		assertFalse(task.isFinished());
		task.finishTask(TaskRating.EXCELLENT);
		assertTrue(task.isFinished());
	}

	public void testFinishTask()
	{
		assertFalse(task.isFinished());
		task.finishTask(TaskRating.GREAT);
		assertTrue(task.isFinished());
		assertEquals(TaskRating.GREAT, task.getRating());

		task.finishTask(null);
		assertTrue(task.isFinished());
		assertEquals(TaskRating.GREAT, task.getRating());

		Task task2 = new TaskImpl();
		assertFalse(task2.isFinished());
		task2.finishTask(null);
		assertFalse(task2.isFinished());
	}

	public void testGetFinishedDate()
	{
		assertNull(task.getFinishedDate());
		task.finishTask(TaskRating.EXCELLENT);
		assertNotNull(task.getFinishedDate());
	}

}
